<template>
  <div class="mod-config">
    <basic-container>
      <navigationZDRW :sign="{ a: true, b: false, c: false }"></navigationZDRW>
      <div class="boxsty zhiBiao" v-if="zhiShow == 1">
        <div :height="searchheight">
          <span
            style="float: right; margin-top: -30px; cursor: pointer"
            @click="searchchangeadvanced"
            >{{ searchadvanced ? "查询条件收起" : "查询条件展开" }}
            <i
              :class="
                searchadvanced ? 'el-icon-arrow-up' : 'el-icon-arrow-down'
              "
            />
          </span>
          <div v-show="searchadvanced">
            <el-form
              :inline="true"
              :model="dataForm"
              @keyup.enter.native="getDataList()"
              class="form-inline"
              label-width="120px"
            >
              <el-form-item label="发起名称">
                <el-input
                  v-model="dataForm.faqiName"
                  placeholder="发起名称"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人姓名">
                <el-input
                  v-model="dataForm.ryName"
                  placeholder="被考核人姓名"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="被考核人岗位">
                <el-input
                  v-model="dataForm.userZw"
                  placeholder="被考核人岗位"
                  :clearable="true"
                  style="width: 150px"
                ></el-input>
              </el-form-item>
              <el-form-item label="任务书状态">
                <el-select
                  style="width: 150px"
                  v-model="dataForm.state"
                  placeholder="请选择"
                  clearable
                >
                  <el-option value="" label="全部"></el-option>
                  <el-option value="0" label="创建中"></el-option>
                  <el-option value="1" label="填报中"></el-option>
                  <el-option value="2" label="审核中"></el-option>
                  <el-option value="3" label="已结束"></el-option>
                  <el-option value="4" label="被考人驳回"></el-option>
                  <el-option value="5" label="汇总完成"></el-option>
                  <el-option value="6" label="汇总驳回"></el-option>
                  <el-option value="7" label="被考核人审核中"></el-option>
                  <el-option value="711" label="被考核人审核完成"></el-option>
                  <el-option value="8" label="被考核人驳回"></el-option>
                  <el-option value="9" label="审定中"></el-option>
                  <el-option value="10" label="审定驳回"></el-option>
                  <el-option value="11" label="文本审核完成"></el-option>
                  <el-option value="12" label="履约中"></el-option>
                  <el-option value="13" label="自评中"></el-option>
                  <el-option value="14" label="评价中"></el-option>
                  <el-option value="15" label="结果汇总完成"></el-option>
                  <el-option value="16" label="领导审核中"></el-option>
                  <el-option value="17" label="领导审核完成"></el-option>
                  <el-option value="18" label="审核结束"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button
                  icon="el-icon-search"
                  type="primary"
                  class="marginLeft"
                  @click="getDataList(1)"
                  >检索
                </el-button>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div
          style="
            display: flex;
            justify-content: space-between;
            border-top: 1px solid #b0bde2;
            padding-top: 10px;
          "
        >
          <div>
            <el-tooltip
              class="item"
              effect="dark"
              content="导入一个任务"
              placement="top"
            >
              <el-button
                icon="el-icon-upload"
                size="small"
                type="success"
                circle
                @click="openImport"
              ></el-button>
            </el-tooltip>
            <el-tooltip
              class="item"
              effect="dark"
              content="下载任务模板"
              placement="top"
            >
              <el-button
                icon="el-icon-download"
                size="small"
                type="warning"
                circle
                @click="exportWord"
              ></el-button>
            </el-tooltip>
            <el-tooltip
              class="item"
              effect="dark"
              content="新增"
              placement="top-start"
            >
              <el-button
                icon="el-icon-plus"
                circle
                type="primary"
                @click="addOrUpdateHandle()"
              ></el-button>
            </el-tooltip>
            <el-tooltip
              class="item"
              effect="dark"
              content="删除"
              placement="top-start"
            >
              <el-button
                icon="el-icon-delete"
                circle
                type="danger"
                @click="deleteBatch()"
                v-loading.fullscreen.lock="Loadingdel"
              ></el-button>
            </el-tooltip>
          </div>
          <div>
            <el-button type="primary" plain @click="ndts()">拟定推送</el-button>
            <el-button
              type="primary"
              plain
              @click="tswb()"
              v-loading.fullscreen.lock="fullscreenLoading"
              >推送文本审核</el-button
            >
            <el-button
              type="primary"
              plain
              @click="shending()"
              v-loading.fullscreen.lock="fullscreenLoading"
              >推送考核委员会审定</el-button
            >
            <el-button
              type="primary"
              plain
              @click="renwuxiada"
              v-loading.fullscreen.lock="Loadingrwxd"
              >任务下达</el-button
            >
          </div>
        </div>
        <div class="avue-crud">
          <el-table
            ref="table"
            style="width: 100%; margin-top: 20px"
            :data="dataList"
            border
            v-if="tableShow"
            v-loading="dataListLoading"
          >
            <el-table-column
              type="selection"
              width="55"
              header-align="center"
              align="center"
            ></el-table-column>
            <el-table-column
              type="index"
              width="80"
              header-align="center"
              align="center"
              label="序号"
            ></el-table-column>
            <el-table-column
              prop="faqiName"
              header-align="center"
              align="center"
              width="200"
              show-overflow-tooltip
              label="发起名称"
            >
            </el-table-column>
            <el-table-column
              prop="userName"
              header-align="center"
              align="center"
              min-width="120"
              show-overflow-tooltip
              label="被考核人编号"
            >
            </el-table-column>
            <el-table-column
              prop="ryName"
              header-align="center"
              align="center"
              min-width="120"
              show-overflow-tooltip
              label="被考核人姓名"
            >
              <template slot-scope="scope">
                <span
                  @click="checkDetails(scope.row)"
                  style="color: #0e258c; cursor: pointer"
                  >{{ scope.row.ryName }}</span
                >
              </template>
            </el-table-column>
            <el-table-column
              prop="userDeptName"
              header-align="center"
              align="center"
              min-width="120"
              show-overflow-tooltip
              label="被考核人单位"
            >
            </el-table-column>
            <el-table-column
              prop="userZj"
              header-align="center"
              align="center"
              label="被考核人职级"
              v-if="showType == 2"
              min-width="180"
              show-overflow-tooltip
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至被考核人岗位">
                  <span
                    ><i
                      @click="switchBtn(1)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >被考核人职级</span
                  >
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              prop="userZw"
              header-align="center"
              align="center"
              min-width="180"
              show-overflow-tooltip
              label="被考核人岗位"
              v-if="showType == 1"
            >
              <template slot="header">
                <el-tooltip placement="top" content="点击切换至被考核人职级">
                  <span
                    ><i
                      @click="switchBtn(2)"
                      class="el-icon-refresh"
                      style="margin-right: 20px"
                    ></i
                    >被考核人岗位</span
                  >
                </el-tooltip>
              </template>
            </el-table-column>
            <el-table-column
              prop="rwCount"
              header-align="center"
              align="center"
              min-width="100"
              show-overflow-tooltip
              label="任务数量"
            >
            </el-table-column>
            <el-table-column
              prop="userLxDsc"
              header-align="center"
              align="center"
              width="100"
              label="发起类型"
            >
            </el-table-column>
            <el-table-column
              prop="auditState"
              header-align="center"
              align="center"
              min-width="120"
              label="子任务状态"
            >
              <template slot-scope="scope">
                <el-popover placement="top" width="240" trigger="hover">
                  <p></p>
                  <div
                    v-for="(item, index) in cutout(
                      scope.row.quotaauditStatusstr
                    )"
                    :key="index"
                  >
                    <el-badge
                      v-if="scope.row.quotaauditStatus != '0'"
                      :value="item.split('-')[1]"
                      :max="9"
                      class="itembadge"
                    >
                      <span
                        v-if="item.indexOf('已完成') != -1"
                        style="color: #0bbf4a"
                        >{{ item.split("-")[0] }}</span
                      >
                      <span
                        v-else-if="item.indexOf('未完成') != -1"
                        style="color: red"
                        >{{ item.split("-")[0] }}</span
                      >
                      <span v-else>{{ item.split("-")[0] }}</span>
                    </el-badge>
                    <span v-else>{{ item.split("-")[0] }}</span>
                  </div>
                  <div slot="reference" class="name-wrapper">
                    <span v-if="scope.row.auditState == 0">填报中</span>
                    <span v-else-if="scope.row.auditState == 1">审核中</span>
                    <span v-else-if="scope.row.auditState == 2">审核驳回</span>
                    <span v-else-if="scope.row.auditState == 3">审核完成</span>
                    <span v-else-if="scope.row.auditState == 4">自评中</span>
                    <span v-else-if="scope.row.auditState == 5">他评中</span>
                    <span v-else-if="scope.row.auditState == 6">评价完成</span>
                    <span v-else-if="scope.row.auditState == 7">已完成</span>
                    <span v-else-if="scope.row.auditState == 8">未完成</span>
                  </div>
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column
              prop="stateExplain"
              header-align="center"
              align="center"
              min-width="120"
              label="任务状态"
            >
              <template slot-scope="scope">
                <div>
                  <el-popover placement="top" width="660" trigger="hover">
                    <el-table :data="scope.row.gridData" max-height="400">
                      <el-table-column
                        width="260"
                        property="NAME_"
                        label="任务名称"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="ry_name"
                        label="处理人"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="START_TIME_"
                        label="开始时间"
                        show-overflow-tooltip
                      ></el-table-column>
                      <el-table-column
                        width="120"
                        property="END_TIME_"
                        label="结束时间"
                        show-overflow-tooltip
                      ></el-table-column>
                    </el-table>
                    <span slot="reference">{{ scope.row.stateExplain }}</span>
                    <el-button
                      type="primary"
                      icon="el-icon-search"
                      @click="showMessage(scope.row.proceid, scope.row)"
                      >流程跟踪</el-button
                    >
                  </el-popover>
                </div>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="avue-crud__pagination">
          <el-pagination
            @size-change="sizeChangeHandle"
            @current-change="currentChangeHandle"
            :current-page="pageIndex"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="pageSize"
            :total="totalPage"
            background
            layout="total, sizes, prev, pager, next, jumper"
          >
          </el-pagination>
        </div>
      </div>
      <!-- 弹窗, 新增  -->
      <RWFQForm
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="getDataList"
        @openZhibiao="openZhibiao"
        :addDataForm="addDataForm"
      ></RWFQForm>
      <!-- 指标维护-->
      <zhibiaoForm
        v-if="zhiShow == 2"
        :zhibiaoForm="zhibiaoForm"
        v-on:zhibiaoChild="zhibiaoChild"
      ></zhibiaoForm>
      <!--      任务书编辑-指标-->
      <zdrwcjForm ref="zdrwcjForm" v-if="zhiShow == 3"></zdrwcjForm>
      <khrwDetailTable
        ref="renwukaohedetail"
        @fnBackLastPage="fnBackLastPage"
      ></khrwDetailTable>
      <!--    发送指标部门-->
      <el-dialog
        title="请选择指标拟定部门"
        :close-on-click-modal="false"
        :visible.sync="zbvisible"
        append-to-body
      >
        <div style="height: 50vh">
          <el-row>
            <el-col :span="8">
              <div class="text-center">
                <el-tree
                  :data="treeOrgData"
                  show-checkbox
                  node-key="id"
                  :default-expanded-keys="[2, 3]"
                  :default-checked-keys="[5]"
                  :props="defaultProps"
                  @check-change="handleCheckChange"
                >
                </el-tree>
              </div>
            </el-col>
          </el-row>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="ts()">推送</el-button>
          <el-button type="primary" plain @click="zbvisible = false"
            >返回</el-button
          >
        </span>
      </el-dialog>
      <el-dialog
        title="重点任务导入"
        :visible.sync="importVisible"
        :show-close="false"
      >
        <el-form
          :model="importForm"
          ref="importForm"
          :rules="dataRule"
          label-width="140px"
        >
          <el-row style="display: flex; justify-content: space-between">
            <el-col :span="12" style="margin-top: 20px">
              <el-form-item label="发起类型:" prop="userLx">
                <el-select
                  class="xiaLa"
                  v-model="importForm.userLx"
                  placeholder="请选择发起类型"
                  style="width: 100%"
                  :clearable="true"
                >
                  <el-option
                    v-for="(item, index) in userLxList"
                    :key="index"
                    :label="item.name"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="填报结束日期:" prop="signDate">
                <el-date-picker
                  v-model="importForm.signDate"
                  type="date"
                  style="width: 100%"
                  value-format="yyyy-MM-dd"
                  placeholder="填报结束日期"
                ></el-date-picker>
              </el-form-item>
              <el-form-item label="模板名称:" prop="templateId">
                <el-select
                  v-model="importForm.templateId"
                  placeholder="模板名称"
                  class="xiaLa"
                  style="width: 100%"
                  :clearable="true"
                >
                  <el-option
                    v-for="(item, index) in categoryList"
                    :key="index"
                    :label="item.templateName"
                    :value="item.id"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col
              :span="12"
              style="display: flex; justify-content: flex-end"
              class="importantBg"
            >
              <el-upload
                ref="upload"
                action=""
                :headers="headers"
                :data="importForm"
                multiple
                :file-list="fileList"
                :before-upload="handleBefore"
                :on-success="handleSuccess"
                :http-request="httpRequest"
                accept=".docx"
              >
                <el-button
                  icon="el-icon-upload"
                  type="success"
                  style="margin-right: 93px"
                  >导入重点任务</el-button
                >
              </el-upload>
            </el-col>
          </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button
            type="primary"
            plain
            @click="uploadBtn('importForm')"
            v-loading.fullscreen.lock="fullscreenLoading"
            >保 存</el-button
          >
          <el-button @click="importVisible = false">取 消</el-button>
        </span>
      </el-dialog>
    </basic-container>
    <processTracking
      ref="processTracking"
      @processTrackingChildren="getDataList"
    ></processTracking>
    <UserCommonSelect ref="usercomment" @submitfy="submitfy"></UserCommonSelect>
  </div>
</template>

<script>
import RWFQForm from "@/views/hetongrenwu/zhongdianrenwu/zhongdianrwcj/rwfqnew/rwfq-form";
import zhibiaoForm from "@/views/hetongrenwu/components/zhibiao-form.vue";
import rwszbForm from "@/views/hetongrenwu/components/renwushuzb-form.vue";
import khrwTable from "@/views/hetongrenwu/components/zhongdian-kaoherenwu-table.vue";
import khrwDetailTable from "@/views/hetongrenwu/zhongdianrenwu/zhongdianrwcj/rwfqnew/zhongdian-kaoherenwu-table-detail.vue";
import zdrwcjForm from "@/views/hetongrenwu/components/zhongdianrwcj-form.vue";
import UserCommonSelect from "@/views/hetongrenwu/hetong/hetongyeji/hetonghtxxdjb/formulateDialog";
import {
  getRenwufaqiPage,
  renwuxiadaByIds,
  deleteBatchRwfq,
  RenwundtsByIds,
  getNiDingList,
  tuisongwenbenByIds,
  tuisongshending,
  exportWord,
} from "@/api/hetongrenwu/zhongdian/renwuchuangjian";
import { getRenWuFaQi } from "@/api/hetongrenwu/zhongdianrenwu/zhongdianrwcj/index";
import { mapGetters } from "vuex";
import processTracking from "./processTracking";
import store from "@/store";
import { effective } from "@/api/hetongrenwu/hetongyeji/hetongnd";

export default {
  components: {
    RWFQForm,
    zhibiaoForm,
    rwszbForm,
    khrwTable,
    khrwDetailTable,
    zdrwcjForm,
    UserCommonSelect,
    processTracking,
  },
  data() {
    return {
      dataRule: {
        userLx: [
          { required: true, message: "请选择发起类型", trigger: "change" },
        ],
        signDate: [
          { required: true, message: "请选择填报结束日期", trigger: "change" },
        ],
        templateId: [
          { required: true, message: "请选择模板名称", trigger: "change" },
        ],
      },
      headers: {
        Authorization: "Bearer " + store.getters.access_token,
      },
      optionsStatus: [
        {
          value: 0,
          label: "创建中",
        },
        {
          value: 1,
          label: "填报中",
        },
        {
          value: 2,
          label: "审批完成",
        },
        {
          value: 3,
          label: "任务已下达",
        },
      ],
      dataForm: {
        key: "",
      },
      categoryList: [],
      importForm: {},
      userLxList: [
        { name: "总部发起", value: "1" },
        { name: "总部自拟", value: "2" },
        { name: "部门自拟", value: "3" },
      ],
      importVisible: false,
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      rwfqvisible: false,
      dataListLoading: false,
      addOrUpdateVisible: false,
      radioTwo: "-1",
      zhiShow: "1",
      zhibiaoForm: {},
      addDataForm: {},
      renwufaqiTableData: {},
      rwszbForm: {},
      searchadvanced: true,
      searchheight: "0",
      zbvisible: false,
      treeOrgData: [],
      selectedTreeData: [],
      defaultProps: {
        children: "children",
        label: "name",
      },
      showType: 1,
      tableShow: true,
      fullscreenLoading: false,
      Loadingrwxd: false,
      Loadingdel: false,
      usercommentTask: false,
      file: [],
      fileList: [],
    };
  },
  watch: {},
  created() {
    this.getDataList();
    this.getTreeData();
  },
  computed: {
    ...mapGetters(["permissions"]),
  },
  methods: {
    searchchangeadvanced() {
      this.searchadvanced = !this.searchadvanced;
      if (this.searchadvanced) {
        this.searchheight = "auto";
      }
    },
    //树结构选中的数据
    handleCheckChange(data) {
      var index = this.selectedTreeData.findIndex(
        (item) => item.deptId == data.deptId
      );
      if (index == -1) {
        this.selectedTreeData.push(data);
      } else {
        this.selectedTreeData.splice(index, 1);
      }
    },
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      getRenwufaqiPage(
        Object.assign(
          {
            isbenbu: this.radioTwo,
            current: this.pageIndex,
            size: this.pageSize,
          },
          this.dataForm
        )
      ).then((response) => {
        this.dataList = response.data.data.records;
        this.totalPage = response.data.data.total;
        this.dataListLoading = false;
      });
    },
    getTreeData() {
      getNiDingList().then((res) => {
        this.treeOrgData = res.data.data;
      });
    },
    switchBtn(e) {
      this.showType = e;
      this.tableShow = false;
      this.$nextTick((res) => {
        this.tableShow = true;
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    cutout(cellValue) {
      if (cellValue) {
        var c = cellValue.split(",");
        if (c.size < 1) {
          c.push("-");
          c.push("-");
        } else if (c.size < 2) {
          c.push("-");
        }
        return c;
      }
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      getRenWuFaQi().then((res) => {
        this.addDataForm = res.data.data;
        if (this.addDataForm === null) {
          this.$message.error("当前没有启动中的任务！");
          return false;
        }

        this.addOrUpdateVisible = true;
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id);
        });
      });
    },
    deleteBatch() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.error("请至少选择一个任务！");
        return;
      }
      var ids = this.checkDateIds(data, [0]);
      if (ids.length == 0) {
        this.$message.error("没有可以删除的任务！");
        return;
      }
      var idsStr = ids.join(",");
      this.$confirm(
        "有" + ids.length + "条可以删除的数据，是否要删除吗？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).then((res) => {
        this.Loadingdel = true;
        deleteBatchRwfq({ ids: idsStr }).then((res) => {
          this.$message.closeAll();
          this.$message.success("删除成功");
          this.getDataList();
          this.Loadingdel = false;
        });
      });
    },
    renwuxiada() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.error("请选择一个任务！");
        return;
      }
      for (var i = 0; i < data.length; i++) {
        if (data[i].state != "11") {
          this.$message.warning("请选择任务状态为“文本审核完成”的数据");
          return;
        }
      }
      var ids = this.checkDateIds(data, [11]);
      if (ids.length == 0) {
        this.$message.error("没有可以下达的任务！");
        return;
      }
      this.$confirm(
        "有" + ids.length + "条可以下达的任务，是否确定下达？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).then((res) => {
        this.Loadingrwxd = true;
        renwuxiadaByIds({ rows: data })
          .then((data) => {
            this.$message.closeAll();
            this.$message.success("下达成功");
            this.getDataList();
            this.Loadingrwxd = false;
          })
          .catch((res) => {
            this.Loadingrwxd = false;
          });
      });
    },
    //子集信息
    renwushuzbChild(data) {
      if (data) {
        this.zhiShow = 1;
      }
    },
    //新增子集返回的数据(关闭修改页面，打开指标库维护)
    openZhibiao(data) {
      this.addOrUpdateVisible = false;
      this.zhiShow = 2;
      this.zhibiaoForm = {
        enter: 0,
        disabled: false,
      };
    },
    //编辑查看
    checkDetails(row) {
      this.$nextTick(() => {
        this.$refs.renwukaohedetail.init(row);
      });
    },

    checkDateIds(data, state) {
      var ids = [];
      state.forEach((ele) => {
        data.forEach(function (item, index) {
          if (item.state == ele) {
            ids.push(item.id);
          }
        });
      });

      return ids;
    },
    ndts() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.error("请选择一个任务！");
        return;
      }
      var ids = this.checkDateIds(data, [0]);
      if (ids.length == 0) {
        this.$message.error("没有可以推送的任务！");
        return;
      }
      var show = "";
      for (var i = 0; i < data.length; i++) {
        for (var j = 0; j < data.length; j++) {
          show = data[i].userLxDsc;
          if (data[i].userLxDsc != data[j].userLxDsc) {
            this.$message.warning("请选择发起类型相同的数据");
            return;
          }
        }
      }
      this.$confirm(
        "有" + ids.length + "条可以推送的数据，是否要拟定推送？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).then((res) => {
        if (show == "总部发起") {
          this.$nextTick(() => {
            this.$refs.usercomment.init(
              "12",
              "rwsndts",
              this.jsonData,
              "rwsndts"
            );
          });
        } else {
          RenwundtsByIds({ rows: this.$refs.table.selection }).then((data) => {
            this.$message.closeAll();
            this.$message.success("拟定推送成功");
            this.getDataList();
          });
        }
      });
    },
    submitfy(data) {
      RenwundtsByIds({
        rows: this.$refs.table.selection,
        selectdata: data.tableDataUser,
        selectorgdata: data.selectorgdata,
        bkhr: data.bkhr,
      }).then((data) => {
        this.$message.closeAll();
        this.$message.success("拟定推送成功");
        this.getDataList();
      });
    },
    shending() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.error("请选择一个任务！");
        return;
      }
      var ids = this.checkDateIds(data, [711]);
      if (ids.length == 0) {
        this.$message.error("没有可以推送考核委员会审定的任务！");
        return;
      }
      this.fullscreenLoading = true;
      tuisongshending({
        rows: data,
      })
        .then((res) => {
          this.$message.success("推送考核委员会审定成功");
          this.fullscreenLoading = false;
          this.getDataList();
        })
        .catch((res) => {
          this.fullscreenLoading = false;
        });
    },
    tswb() {
      var data = this.$refs.table.selection;
      if (data.length == 0) {
        this.$message.error("请选择一个任务！");
        return;
      }

      var ids = this.checkDateIds(data, [5, 8, 10]);
      if (ids.length == 0) {
        this.$message.error("没有可以推送文本审核的任务！");
        return;
      }

      this.$confirm(
        "有" + ids.length + "条可以推送文本审核,是否继续推送？",
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      ).then((res) => {
        this.fullscreenLoading = true;
        tuisongwenbenByIds({ rows: data })
          .then((res) => {
            this.$message.closeAll();
            this.$message.success("推送文本审核成功！");
            this.fullscreenLoading = false;
            this.getDataList();
          })
          .catch((res) => {
            this.fullscreenLoading = false;
          });
      });
    },
    //变价查看子集信息返回
    zhibiaoChild(zhibiaoChild) {
      if (zhibiaoChild) {
        this.zhiShow = 1;
      }
    },
    fnBackLastPage(data) {
      if (data == "返回原页面") {
        this.getDataList();
      }
    },
    showMessage(proId, row) {
      console.log(row);
      this.$refs.processTracking.init(proId);
    },
    exportWord() {
      exportWord().then((response) => {
        this.$message.closeAll();
        this.$message.success("下载成功!");
        let url = window.URL.createObjectURL(new Blob([response.data]));
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.setAttribute("download", "重点任务模板.docx");
        document.body.appendChild(link);
        link.click();
      });
    },
    openImport() {
      this.file = [];
      this.importForm = {};
      this.fileList = [];
      this.importVisible = true;
      this.fneffective();
    },
    httpRequest(param) {
      this.file.push(param.file); // 一般情况下是在这里创建FormData对象，但我们需要上传多个文件，为避免发送多次请求，因此在这里只进行文件的获取，param可以拿到文件上传的所有信息
    },
    handleBefore(file) {
      return new Promise((resolve, reject) => {
        var forms = new FormData();
        var configs = {
          headers: {
            "Content-Type": "multipart/form-data",
            Authorization: "Bearer " + store.getters.access_token,
          },
        };
        forms.append("file", file);
        forms.append("userLx", this.importForm.userLx);
        this.axios
          .post("/appr-contract/zdrwcj/importZdrwCheck", forms, configs)
          .then((res) => {
            if (res.data.data != null) {
              this.$message.error(res.data.data);
              return reject(false);
            } else {
              return resolve(true);
            }
          });
      });
    },
    uploadBtn(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.fullscreenLoading = true;
          var upData = new FormData();
          upData.append("userLx", this.importForm.userLx);
          upData.append("signDate", this.importForm.signDate);
          upData.append("templateId", this.importForm.templateId);
          setTimeout(() => {
            this.file.forEach(function (file) {
              // 因为要上传多个文件，所以需要遍历
              upData.append("file", file, file.name);
            });
            this.axios
              .post("/appr-contract/zdrwcj/importZdrw", upData)
              .then((res) => {
                this.importVisible = false;
                this.$message.success("导入成功");
                this.getDataList();
                this.fullscreenLoading = false;
              })
              .catch(function (error) {
                console.log(error);
                this.fullscreenLoading = false;
              });
          }, 9000);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    handleSuccess() {
      this.importVisible = false;
      this.$message.success("导入成功");
      this.getDataList();
    },
    // 获取下拉
    fneffective() {
      effective({
        tagName: "重点任务",
      }).then((res) => {
        this.categoryList = res.data.data;
      });
    },
  },
};
</script>
<style>
.importantBg {
  width: 45%;
  border-radius: 16px;
  padding: 10px;
  box-shadow: 4px 4px 6px #888888;
  background: #fff;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
}
.importantBg .el-upload-list {
  overflow-y: scroll;
  height: 150px;
}
</style>
